<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>医院预约系统实体属性关系图</title>
    <script src="https://cdn.jsdelivr.net/npm/mermaid@10.6.1/dist/mermaid.min.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/mermaid@10.6.1/dist/mermaid.min.css">
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background-color: #f5f5f5;
            margin: 0;
            padding: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        .container {
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            padding: 20px;
            margin-bottom: 20px;
            max-width: 1200px;
            width: 100%;
        }
        h1 {
            color: #2c3e50;
            text-align: center;
            margin-bottom: 30px;
        }
        .mermaid {
            margin: 30px 0;
            display: flex;
            justify-content: center;
        }
        .mermaid svg {
            max-width: 100%;
            height: auto;
        }
        .primary-key {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>医院预约系统实体属性关系图</h1>
        <div class="mermaid">
            graph TD
                %% 实体定义
                User[用户]
                Doctor[医生]
                Department[科室]
                Schedule[排班]
                Appointment[预约]
                HealthCheck[健康打卡]
                Post[帖子]
                Comment[评论]
                Favorite[收藏]

                %% 属性定义（主键加下划线）
                UserId((<u>id</u>))
                UserName((username))
                UserPassword((password))
                UserRole((role))
                UserPhone((phone))
                UserEmail((email))
                UserStatus((status))

                DoctorId((<u>id</u>))
                DoctorName((name))
                DoctorTitle((title))
                DoctorSpecialty((specialty))
                DoctorStatus((status))

                DeptId((<u>id</u>))
                DeptName((name))
                DeptDesc((description))
                DeptStatus((status))

                ScheduleId((<u>id</u>))
                ScheduleDate((schedule_date))
                SchedulePeriod((period))
                ScheduleMax((max_appointments))
                ScheduleAvailable((available_appointments))

                AppointmentId((<u>id</u>))
                AppointmentTime((appointment_time))
                AppointmentStatus((status))
                AppointmentDesc((description))

                HealthCheckId((<u>id</u>))
                HealthCheckType((type))
                HealthCheckContent((content))
                HealthCheckDuration((duration))
                HealthCheckMood((mood))

                PostId((<u>id</u>))
                PostTitle((title))
                PostContent((content))
                PostViews((views))
                PostLikes((likes))

                CommentId((<u>id</u>))
                CommentContent((content))
                CommentLikes((likes))

                %% 连接实体和属性
                User --- UserId
                User --- UserName
                User --- UserPassword
                User --- UserRole
                User --- UserPhone
                User --- UserEmail
                User --- UserStatus

                Doctor --- DoctorId
                Doctor --- DoctorName
                Doctor --- DoctorTitle
                Doctor --- DoctorSpecialty
                Doctor --- DoctorStatus

                Department --- DeptId
                Department --- DeptName
                Department --- DeptDesc
                Department --- DeptStatus

                Schedule --- ScheduleId
                Schedule --- ScheduleDate
                Schedule --- SchedulePeriod
                Schedule --- ScheduleMax
                Schedule --- ScheduleAvailable

                Appointment --- AppointmentId
                Appointment --- AppointmentTime
                Appointment --- AppointmentStatus
                Appointment --- AppointmentDesc

                HealthCheck --- HealthCheckId
                HealthCheck --- HealthCheckType
                HealthCheck --- HealthCheckContent
                HealthCheck --- HealthCheckDuration
                HealthCheck --- HealthCheckMood

                Post --- PostId
                Post --- PostTitle
                Post --- PostContent
                Post --- PostViews
                Post --- PostLikes

                Comment --- CommentId
                Comment --- CommentContent
                Comment --- CommentLikes

                %% 主键标注
                UserId -.->|PK| User
                DoctorId -.->|PK| Doctor
                DeptId -.->|PK| Department
                ScheduleId -.->|PK| Schedule
                AppointmentId -.->|PK| Appointment
                HealthCheckId -.->|PK| HealthCheck
                PostId -.->|PK| Post
                CommentId -.->|PK| Comment
        </div>
    </div>
    <script>
        mermaid.initialize({
            theme: 'default',
            startOnLoad: true,
            securityLevel: 'loose',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true
            }
        });
    </script>
</body>
</html> 